/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * articulos_sie_traspaso_requisicion.java
 *
 * Created on 8/04/2011, 03:05:39 PM
 */

package sie_invdis;


import java.sql.*;
import javax.swing.*;

import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.JTable.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Date;
import java.util.Calendar;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.text.*;
import javax.swing.JFrame;


/**
 *
 * @author Michelle
 */
public class articulos_sie_traspaso_requisicion extends javax.swing.JFrame {

     private javax.swing.table.DefaultTableModel jtable_modelo;
     private javax.swing.table.DefaultTableModel jtable_modeloexistencia;
     private javax.swing.table.DefaultTableModel jtable_modelorequisicion;
      //private javax.swing.table.DefaultTableModel jtable_tiendas;
      private JTable jtable_tiendas;
      private java.util.Date fechahoy=new Date();
      private int visualisa=0;
      private String esquesele="";
      bd_conexion x = new bd_conexion();
      ResultSet rs = null,rs2=null;
      private SimpleDateFormat formateadoresta = new SimpleDateFormat("yyyy-MM-dd");
      private int ordenamiento=0,controlcombo=0;
    /** Creates new form articulos_sie_traspaso_requisicion */
    public articulos_sie_traspaso_requisicion() {
        this.iniciar_modelo_de_tabla();
        this.iniciar_modelo_existencia();
        this.iniciar_modelo_requisicion();
        initComponents();
        
        this.setLocation(5,5);
        this.loadcombo();

        Calendar fechaini = Calendar.getInstance(); // obtiene la fecha actual
        fechaini.set(fechahoy.getYear()+1900,fechahoy.getMonth(), 1);

        this.jdc_fechainicial.setDate(fechaini.getTime());
        this.jdc_fechafinal.setDate(fechahoy);
        this.jdc_fechadocto.setDate(fechahoy);

    jtb_articmasven.getColumnModel().getColumn(0).setPreferredWidth(15);//tem ent
    jtb_articmasven.getColumnModel().getColumn(1).setPreferredWidth(15);//familia
    jtb_articmasven.getColumnModel().getColumn(2).setPreferredWidth(60);//subfam.
    jtb_articmasven.getColumnModel().getColumn(3).setPreferredWidth(85);//id
    jtb_articmasven.getColumnModel().getColumn(4).setPreferredWidth(60);//clave
    jtb_articmasven.getColumnModel().getColumn(5).setPreferredWidth(20);//descrip.
    jtb_articmasven.getColumnModel().getColumn(6).setPreferredWidth(15);//item
    jtb_articmasven.getColumnModel().getColumn(7).setPreferredWidth(15);//item
    jtb_articmasven.getColumnModel().getColumn(8).setPreferredWidth(15);//item

    jtb_articmasven.getTableHeader().setBackground(Color.yellow);


    jtble_existenciaalmacenes.getColumnModel().getColumn(0).setPreferredWidth(15);//tem ent
    jtble_existenciaalmacenes.getColumnModel().getColumn(1).setPreferredWidth(35);//familia
    jtble_existenciaalmacenes.getColumnModel().getColumn(2).setPreferredWidth(60);//subfam.
    jtble_existenciaalmacenes.getColumnModel().getColumn(3).setPreferredWidth(85);//id
    jtble_existenciaalmacenes.getColumnModel().getColumn(4).setPreferredWidth(15);//clave
    jtble_existenciaalmacenes.getColumnModel().getColumn(5).setPreferredWidth(15);//clave
    jtble_existenciaalmacenes.getColumnModel().getColumn(6).setPreferredWidth(15);//clave

    jtble_existenciaalmacenes.getTableHeader().setBackground(Color.yellow);

    jtble_requiciciones.getColumnModel().getColumn(0).setPreferredWidth(15);//tem ent
    jtble_requiciciones.getColumnModel().getColumn(1).setPreferredWidth(15);//familia
    jtble_requiciciones.getColumnModel().getColumn(2).setPreferredWidth(60);//subfam.
    jtble_requiciciones.getColumnModel().getColumn(3).setPreferredWidth(85);//id
    jtble_requiciciones.getColumnModel().getColumn(4).setPreferredWidth(15);//clave
    jtble_requiciciones.getColumnModel().getColumn(5).setPreferredWidth(60);//clave
    

    jtble_requiciciones.getTableHeader().setBackground(Color.yellow);

    controlcombo=1;
    esquesele=String.valueOf(variables_global.getidtiendami());
    
    }
 private void iniciar_modelo_de_tabla()
    {
        jtable_modelo=new javax.swing.table.DefaultTableModel();//Creo el modelo
        jtable_modelo.addColumn("<html><b>Familia</b></html>");
        jtable_modelo.addColumn("<html><b>Id</b></html>");
        jtable_modelo.addColumn("<html><b>Clave</b></html>");
        jtable_modelo.addColumn("<html><b>Descripcion</b></html>");
        jtable_modelo.addColumn("<html><b>Item</b></html>");
        jtable_modelo.addColumn("<html><b>Pz Ven.</b></html>");
        jtable_modelo.addColumn("<html><b>E.Min</b></html>");
        jtable_modelo.addColumn("<html><b>E.Max</b></html>");
        jtable_modelo.addColumn("<html><b>Exist.</b></html>");
   }
  private void iniciar_modelo_existencia()
    {
        jtable_modeloexistencia=new javax.swing.table.DefaultTableModel();//Creo el modelo
        jtable_modeloexistencia.addColumn("<html><b>Cli</b></html>");
        jtable_modeloexistencia.addColumn("<html><b>Tienda</b></html>");
        jtable_modeloexistencia.addColumn("<html><b>Articulo</b></html>");
        jtable_modeloexistencia.addColumn("<html><b>Descripcion</b></html>");
        jtable_modeloexistencia.addColumn("<html><b>E.Min</b></html>");
        jtable_modeloexistencia.addColumn("<html><b>E.Max</b></html>");
        jtable_modeloexistencia.addColumn("<html><b>Exist.</b></html>");
   }
  private void iniciar_modelo_requisicion()
    {
        jtable_modelorequisicion=new javax.swing.table.DefaultTableModel();//Creo el modelo
        jtable_modelorequisicion.addColumn("<html><b>T.Sol</b></html>");
        jtable_modelorequisicion.addColumn("<html><b>Provee</b></html>");
        jtable_modelorequisicion.addColumn("<html><b>Articulo</b></html>");
        jtable_modelorequisicion.addColumn("<html><b>Descripcion</b></html>");
        jtable_modelorequisicion.addColumn("<html><b>Cant.</b></html>");
        jtable_modelorequisicion.addColumn("<html><b>Observ.</b></html>");
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jdc_fechainicial = new com.toedter.calendar.JDateChooser();
        jLabel2 = new javax.swing.JLabel();
        jdc_fechafinal = new com.toedter.calendar.JDateChooser();
        jrbtn_estemes = new javax.swing.JRadioButton();
        jrbtn_mespasada = new javax.swing.JRadioButton();
        jrbtn_mesactuaante = new javax.swing.JRadioButton();
        jbtn_generareporte = new javax.swing.JButton();
        jcbx_tiendas = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtb_articmasven = new javax.swing.JTable()
        {
            public boolean isCellEditable(int rowIndex, int mColIndex) {
                return false;
            }}
            ;
            jPanel5 = new javax.swing.JPanel();
            jScrollPane3 = new javax.swing.JScrollPane();
            jtble_requiciciones = new javax.swing.JTable(){
                public boolean isCellEditable(int rowIndex, int mColIndex) {
                    if (mColIndex < 4)
                    return false;
                    else
                    return true;
                }}
                ;
                jtf_observaciones = new javax.swing.JTextField();
                jLabel3 = new javax.swing.JLabel();
                jdc_fechadocto = new com.toedter.calendar.JDateChooser();
                jbtn_guardar = new javax.swing.JButton();
                jPanel6 = new javax.swing.JPanel();
                jScrollPane2 = new javax.swing.JScrollPane();
                jtble_existenciaalmacenes = new javax.swing.JTable()
                {
                    public boolean isCellEditable(int rowIndex, int mColIndex) {
                        return false;
                    }}
                    ;
                    jPanel7 = new javax.swing.JPanel();
                    jScrollPane4 = new javax.swing.JScrollPane();
                    jep_imagen = new javax.swing.JEditorPane();
                    jCheckBox1 = new javax.swing.JCheckBox();
                    jtf_idactual = new javax.swing.JTextField();
                    jMenuBar1 = new javax.swing.JMenuBar();
                    jMenu1 = new javax.swing.JMenu();
                    jMenuItem1 = new javax.swing.JMenuItem();
                    jmni_salir = new javax.swing.JMenuItem();
                    jMenu2 = new javax.swing.JMenu();
                    jmni_escape = new javax.swing.JMenuItem();
                    jmni_guardar = new javax.swing.JMenuItem();
                    jMenu3 = new javax.swing.JMenu();

                    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
                    org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(sie_invdis.Sie_invdisApp.class).getContext().getResourceMap(articulos_sie_traspaso_requisicion.class);
                    setTitle(resourceMap.getString("Form.title")); // NOI18N
                    setName("Form"); // NOI18N

                    jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel2.border.title"))); // NOI18N
                    jPanel2.setName("jPanel2"); // NOI18N

                    jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
                    jLabel1.setName("jLabel1"); // NOI18N

                    jdc_fechainicial.setToolTipText(resourceMap.getString("jdc_fechainicial.toolTipText")); // NOI18N
                    jdc_fechainicial.setDateFormatString(resourceMap.getString("jdc_fechainicial.dateFormatString")); // NOI18N
                    jdc_fechainicial.setName("jdc_fechainicial"); // NOI18N
                    jdc_fechainicial.addInputMethodListener(new java.awt.event.InputMethodListener() {
                        public void caretPositionChanged(java.awt.event.InputMethodEvent evt) {
                        }
                        public void inputMethodTextChanged(java.awt.event.InputMethodEvent evt) {
                            jdc_fechainicialInputMethodTextChanged(evt);
                        }
                    });
                    jdc_fechainicial.addKeyListener(new java.awt.event.KeyAdapter() {
                        public void keyPressed(java.awt.event.KeyEvent evt) {
                            jdc_fechainicialKeyPressed(evt);
                        }
                    });

                    jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
                    jLabel2.setName("jLabel2"); // NOI18N

                    jdc_fechafinal.setToolTipText(resourceMap.getString("jdc_fechafinal.toolTipText")); // NOI18N
                    jdc_fechafinal.setDateFormatString(resourceMap.getString("jdc_fechafinal.dateFormatString")); // NOI18N
                    jdc_fechafinal.setMaxSelectableDate(new java.util.Date(253370790102000L));
                    jdc_fechafinal.setName("jdc_fechafinal"); // NOI18N

                    jrbtn_estemes.setText(resourceMap.getString("jrbtn_estemes.text")); // NOI18N
                    jrbtn_estemes.setToolTipText(resourceMap.getString("jrbtn_estemes.toolTipText")); // NOI18N
                    jrbtn_estemes.setName("jrbtn_estemes"); // NOI18N
                    jrbtn_estemes.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
                            jrbtn_estemesActionPerformed(evt);
                        }
                    });

                    jrbtn_mespasada.setText(resourceMap.getString("jrbtn_mespasada.text")); // NOI18N
                    jrbtn_mespasada.setToolTipText(resourceMap.getString("jrbtn_mespasada.toolTipText")); // NOI18N
                    jrbtn_mespasada.setName("jrbtn_mespasada"); // NOI18N
                    jrbtn_mespasada.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
                            jrbtn_mespasadaActionPerformed(evt);
                        }
                    });

                    jrbtn_mesactuaante.setText(resourceMap.getString("jrbtn_mesactuaante.text")); // NOI18N
                    jrbtn_mesactuaante.setToolTipText(resourceMap.getString("jrbtn_mesactuaante.toolTipText")); // NOI18N
                    jrbtn_mesactuaante.setName("jrbtn_mesactuaante"); // NOI18N
                    jrbtn_mesactuaante.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
                            jrbtn_mesactuaanteActionPerformed(evt);
                        }
                    });

                    jbtn_generareporte.setIcon(resourceMap.getIcon("jbtn_generareporte.icon")); // NOI18N
                    jbtn_generareporte.setText(resourceMap.getString("jbtn_generareporte.text")); // NOI18N
                    jbtn_generareporte.setName("jbtn_generareporte"); // NOI18N
                    jbtn_generareporte.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
                            jbtn_generareporteActionPerformed(evt);
                        }
                    });

                    jcbx_tiendas.setToolTipText(resourceMap.getString("jcbx_tiendas.toolTipText")); // NOI18N
                    jcbx_tiendas.setName("jcbx_tiendas"); // NOI18N
                    jcbx_tiendas.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
                            jcbx_tiendasActionPerformed(evt);
                        }
                    });

                    jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
                    jLabel4.setName("jLabel4"); // NOI18N

                    javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
                    jPanel2.setLayout(jPanel2Layout);
                    jPanel2Layout.setHorizontalGroup(
                        jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel2Layout.createSequentialGroup()
                            .addContainerGap()
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jrbtn_estemes)
                                .addComponent(jLabel1))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel2Layout.createSequentialGroup()
                                    .addComponent(jdc_fechainicial, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jdc_fechafinal, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jbtn_generareporte))
                                .addGroup(jPanel2Layout.createSequentialGroup()
                                    .addComponent(jrbtn_mespasada)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jrbtn_mesactuaante)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jLabel4)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jcbx_tiendas, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addContainerGap(133, Short.MAX_VALUE))
                    );
                    jPanel2Layout.setVerticalGroup(
                        jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel2Layout.createSequentialGroup()
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jdc_fechainicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel2)
                                .addComponent(jdc_fechafinal, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jbtn_generareporte))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jrbtn_mespasada, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jrbtn_mesactuaante, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel4)
                                .addComponent(jcbx_tiendas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jrbtn_estemes, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addContainerGap())
                    );

                    jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel3.border.title"))); // NOI18N
                    jPanel3.setName("jPanel3"); // NOI18N

                    jScrollPane1.setName("jScrollPane1"); // NOI18N

                    jtb_articmasven.setModel(this.jtable_modelo);
                    jtb_articmasven.setName("jtb_articmasven");
                    jtb_articmasven.addMouseListener(new java.awt.event.MouseAdapter() {
                        public void mouseClicked(java.awt.event.MouseEvent evt) {
                            jtb_articmasvenMouseClicked(evt);
                            if(evt.getClickCount() >= 1)
                            {
                                dioclick(evt);
                                //System.out.println(" double click" );

                            }
                        }
                    });
                    jtb_articmasven.addMouseListener(new java.awt.event.MouseAdapter() {
                        public void mouseClicked(java.awt.event.MouseEvent evt) {
                            jtb_articmasvenMouseClicked(evt);
                        }
                    });
                    jScrollPane1.setViewportView(jtb_articmasven);

                    javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
                    jPanel3.setLayout(jPanel3Layout);
                    jPanel3Layout.setHorizontalGroup(
                        jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 614, Short.MAX_VALUE)
                    );
                    jPanel3Layout.setVerticalGroup(
                        jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 547, javax.swing.GroupLayout.PREFERRED_SIZE)
                    );

                    jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel5.border.title"))); // NOI18N
                    jPanel5.setName("jPanel5"); // NOI18N

                    jScrollPane3.setName("jScrollPane3"); // NOI18N

                    jtble_requiciciones.setModel(this.jtable_modelorequisicion);
                    jtble_requiciciones.setName("jtble_requiciciones"); // NOI18N
                    jScrollPane3.setViewportView(jtble_requiciciones);

                    jtf_observaciones.setName("jtf_observaciones"); // NOI18N

                    jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
                    jLabel3.setName("jLabel3"); // NOI18N

                    jdc_fechadocto.setToolTipText(resourceMap.getString("jdc_fechadocto.toolTipText")); // NOI18N
                    jdc_fechadocto.setDateFormatString(resourceMap.getString("jdc_fechadocto.dateFormatString")); // NOI18N
                    jdc_fechadocto.setMaxSelectableDate(new java.util.Date(253370790102000L));
                    jdc_fechadocto.setName("jdc_fechadocto"); // NOI18N

                    jbtn_guardar.setIcon(resourceMap.getIcon("jbtn_guardar.icon")); // NOI18N
                    jbtn_guardar.setText(resourceMap.getString("jbtn_guardar.text")); // NOI18N
                    jbtn_guardar.setName("jbtn_guardar"); // NOI18N
                    jbtn_guardar.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
                            jbtn_guardarActionPerformed(evt);
                        }
                    });

                    javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
                    jPanel5.setLayout(jPanel5Layout);
                    jPanel5Layout.setHorizontalGroup(
                        jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel5Layout.createSequentialGroup()
                            .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel5Layout.createSequentialGroup()
                                    .addComponent(jdc_fechadocto, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jLabel3)
                                    .addGap(2, 2, 2)
                                    .addComponent(jtf_observaciones, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jbtn_guardar, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 393, Short.MAX_VALUE))
                            .addContainerGap())
                    );
                    jPanel5Layout.setVerticalGroup(
                        jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jdc_fechadocto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel3)
                                    .addComponent(jtf_observaciones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jbtn_guardar)))
                            .addContainerGap())
                    );

                    jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel6.border.title"))); // NOI18N
                    jPanel6.setName("jPanel6"); // NOI18N

                    jScrollPane2.setName("jScrollPane2"); // NOI18N

                    jtble_existenciaalmacenes.setModel(this.jtable_modeloexistencia);
                    jtble_existenciaalmacenes.setName("jtble_existenciaalmacenes");
                    jtble_existenciaalmacenes.addMouseListener(new java.awt.event.MouseAdapter() {
                        public void mouseClicked(java.awt.event.MouseEvent evt) {
                            jtble_existenciaalmacenesMouseClicked(evt);
                            if(evt.getClickCount() >= 2)
                            {
                                dioclickalmacen(evt);
                                //System.out.println(" double click" );

                            }
                        }
                    });
                    jScrollPane2.setViewportView(jtble_existenciaalmacenes);

                    javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
                    jPanel6.setLayout(jPanel6Layout);
                    jPanel6Layout.setHorizontalGroup(
                        jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 401, Short.MAX_VALUE)
                    );
                    jPanel6Layout.setVerticalGroup(
                        jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 137, Short.MAX_VALUE)
                    );

                    jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel7.border.title"))); // NOI18N
                    jPanel7.setName("jPanel7"); // NOI18N

                    jScrollPane4.setName("jScrollPane4"); // NOI18N

                    jep_imagen.setContentType(resourceMap.getString("jep_imagen.contentType")); // NOI18N
                    jep_imagen.setName("jep_imagen"); // NOI18N
                    jScrollPane4.setViewportView(jep_imagen);

                    jCheckBox1.setText(resourceMap.getString("jCheckBox1.text")); // NOI18N
                    jCheckBox1.setName("jCheckBox1"); // NOI18N
                    jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
                            jCheckBox1ActionPerformed(evt);
                        }
                    });

                    jtf_idactual.setEditable(false);
                    jtf_idactual.setText(resourceMap.getString("jtf_idactual.text")); // NOI18N
                    jtf_idactual.setName("jtf_idactual"); // NOI18N

                    javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
                    jPanel7.setLayout(jPanel7Layout);
                    jPanel7Layout.setHorizontalGroup(
                        jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel7Layout.createSequentialGroup()
                            .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 382, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(jPanel7Layout.createSequentialGroup()
                                    .addComponent(jtf_idactual, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(95, 95, 95)
                                    .addComponent(jCheckBox1)))
                            .addContainerGap(19, Short.MAX_VALUE))
                    );
                    jPanel7Layout.setVerticalGroup(
                        jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel7Layout.createSequentialGroup()
                            .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 232, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jCheckBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 13, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jtf_idactual, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    );

                    jMenuBar1.setName("jMenuBar1"); // NOI18N

                    jMenu1.setText(resourceMap.getString("jMenu1.text")); // NOI18N
                    jMenu1.setName("jMenu1"); // NOI18N

                    jMenuItem1.setText("jMenuItem1");
                    jMenuItem1.setName("jMenuItem1"); // NOI18N
                    jMenu1.add(jMenuItem1);

                    jmni_salir.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK));
                    jmni_salir.setIcon(resourceMap.getIcon("jmni_salir.icon")); // NOI18N
                    jmni_salir.setText(resourceMap.getString("jmni_salir.text")); // NOI18N
                    jmni_salir.setName("jmni_salir"); // NOI18N
                    jmni_salir.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
                            jmni_salirActionPerformed(evt);
                        }
                    });
                    jMenu1.add(jmni_salir);

                    jMenuBar1.add(jMenu1);

                    jMenu2.setText(resourceMap.getString("jMenu2.text")); // NOI18N
                    jMenu2.setName("jMenu2"); // NOI18N

                    jmni_escape.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0));
                    jmni_escape.setText(resourceMap.getString("jmni_escape.text")); // NOI18N
                    jmni_escape.setName("jmni_escape"); // NOI18N
                    jmni_escape.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
                            jmni_escapeActionPerformed(evt);
                        }
                    });
                    jMenu2.add(jmni_escape);

                    jmni_guardar.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F7, 0));
                    jmni_guardar.setText(resourceMap.getString("jmni_guardar.text")); // NOI18N
                    jmni_guardar.setName("jmni_guardar"); // NOI18N
                    jmni_guardar.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent evt) {
                            jmni_guardarActionPerformed(evt);
                        }
                    });
                    jMenu2.add(jmni_guardar);

                    jMenuBar1.add(jMenu2);

                    jMenu3.setText(resourceMap.getString("jMenu3.text")); // NOI18N
                    jMenu3.setName("jMenu3"); // NOI18N
                    jMenuBar1.add(jMenu3);

                    setJMenuBar(jMenuBar1);

                    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
                    getContentPane().setLayout(layout);
                    layout.setHorizontalGroup(
                        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, 417, Short.MAX_VALUE))
                            .addContainerGap())
                    );
                    layout.setVerticalGroup(
                        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addContainerGap())
                    );

                    pack();
                }// </editor-fold>//GEN-END:initComponents

    private void jdc_fechainicialInputMethodTextChanged(java.awt.event.InputMethodEvent evt) {//GEN-FIRST:event_jdc_fechainicialInputMethodTextChanged
        // TODO add your handling code here:
}//GEN-LAST:event_jdc_fechainicialInputMethodTextChanged

    private void jdc_fechainicialKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jdc_fechainicialKeyPressed
        // TODO add your handling code here:
}//GEN-LAST:event_jdc_fechainicialKeyPressed

    private void jrbtn_estemesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrbtn_estemesActionPerformed
        // TODO add your handling code here:
        Calendar fechaini = Calendar.getInstance(); // obtiene la fecha actual
        fechaini.set(fechahoy.getYear()+1900,fechahoy.getMonth(), 1);
        this.jdc_fechainicial.setDate(fechaini.getTime());
        this.jdc_fechafinal.setDate(fechahoy);
}//GEN-LAST:event_jrbtn_estemesActionPerformed

    private void jrbtn_mespasadaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrbtn_mespasadaActionPerformed
        // TODO add your handling code here:
        Calendar fechamesini = Calendar.getInstance(); // obtiene la fecha actual
        //establesemos la fecha en base a la de hoy menos 1 mes en el dia 1
        fechamesini.set(fechahoy.getYear()+1900,fechahoy.getMonth()-1, 1);
        this.jdc_fechainicial.setDate(fechamesini.getTime());
        //vemos cual fue el ultimo dia del mes anterior restando los dias del mes actual
        fechamesini = Calendar.getInstance(); // obtiene la fecha actual
        int diadelmesactua=fechamesini.get(Calendar.DAY_OF_MONTH);
        fechamesini.add(Calendar.DATE, -diadelmesactua); // se resta el numero de dias del mes
        this.jdc_fechafinal.setDate(fechamesini.getTime());
}//GEN-LAST:event_jrbtn_mespasadaActionPerformed

    private void jrbtn_mesactuaanteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrbtn_mesactuaanteActionPerformed
        // TODO add your handling code here:
        Calendar fechamesini = Calendar.getInstance(); // obtiene la fecha actual
        this.jdc_fechafinal.setDate(fechamesini.getTime());
        //establesemos la fecha en base a la de hoy menos 1 mes en el dia 1
        fechamesini.set(fechahoy.getYear()+1900,fechahoy.getMonth()-1, 1);
        this.jdc_fechainicial.setDate(fechamesini.getTime());
}//GEN-LAST:event_jrbtn_mesactuaanteActionPerformed

    private void jcbx_tiendasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbx_tiendasActionPerformed
        // TODO add your handling code here:
        
   if (controlcombo > 0 )
        {
            String arreglo_idtie[]=null;
            arreglo_idtie=this.jcbx_tiendas.getSelectedItem().toString().split(":");
            esquesele=arreglo_idtie[0];
            this.jbtn_generareporteActionPerformed(evt);
        }

        //this.jtfpruebados.setText(jtable_tiendas.getValueAt(indeceta, 0).toString());
}//GEN-LAST:event_jcbx_tiendasActionPerformed

    private void jbtn_generareporteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_generareporteActionPerformed
        // TODO add your handling code here:
         if(JOptionPane.showConfirmDialog(null, "Estan Correctos sus Datos?")==0) {
            this.contruir_reporte(this.jdc_fechainicial.getDate(),this.jdc_fechafinal.getDate(),ordenamiento,esquesele);
        }
    }//GEN-LAST:event_jbtn_generareporteActionPerformed

    private void jtb_articmasvenMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jtb_articmasvenMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_jtb_articmasvenMouseClicked

    private void jmni_salirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_salirActionPerformed
        // TODO add your handling code here:
       if(JOptionPane.showConfirmDialog(null, "Desea Salir?")==0)
        {
             this.dispose();
        }
    }//GEN-LAST:event_jmni_salirActionPerformed

    private void jmni_escapeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_escapeActionPerformed
        // TODO add your handling code here:
        this.jmni_salirActionPerformed(evt);
    }//GEN-LAST:event_jmni_escapeActionPerformed

    private void jbtn_guardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_guardarActionPerformed
        // TODO add your handling code here:
        if(JOptionPane.showConfirmDialog(null, "Desea Guardar Requisicion?")==0)
             {
                    int numerofilas=this.jtable_modelorequisicion.getRowCount();
                    if(numerofilas>0)
                        {
                            this.guarda_requisision();
                        }
                    else
                        {
                            JOptionPane.showMessageDialog(null,"No Existen Registros", "Sistema Integral(Requisicion Almacen) : Error",1);
                        }
             }
    }//GEN-LAST:event_jbtn_guardarActionPerformed

    private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed
        // TODO add your handling code here:
        articulos_sie_editar fase=new articulos_sie_editar(this.jtf_idactual.getText().toString());
        fase.pack();
        fase.setVisible(true);
    }//GEN-LAST:event_jCheckBox1ActionPerformed

    private void jmni_guardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_guardarActionPerformed
        // TODO add your handling code here:
        this.jbtn_guardarActionPerformed(evt);
    }//GEN-LAST:event_jmni_guardarActionPerformed

 private void loadcombo(){
        jtable_tiendas=variables_global.gettabla_tiendas();
        int numerotiendas=this.jtable_tiendas.getRowCount();
        if (variables_global.getnivelusu()==3 )
            {
                this.jcbx_tiendas.addItem(variables_global.getidtiendami()+":"+variables_global.getidtiendami()+":"+variables_global.getcliente_tistribucion());
            }
        else
            {
            this.jcbx_tiendas.addItem("0:Elige Tienda");
            for(int ii=0;ii<numerotiendas;ii++)
                {
                    this.jcbx_tiendas.addItem(jtable_tiendas.getValueAt(ii, 1)+":"+jtable_tiendas.getValueAt(ii, 0)+":"+jtable_tiendas.getValueAt(ii, 3));
                }
            }
    }


private void guarda_requisision()
    {
        ResultSet rs = null;
        float cantidad=0;
        int nobjetotabla=this.jtble_requiciciones.getRowCount();
        int fi=0,controlfolio=0;
        String cadenafilas="{'", arreglo_articulos[]=null;
        JPasswordField pwd = new JPasswordField(10);
        this.quitarfotosestereporte();
        //lanso la confirmacion de password
        int action = JOptionPane.showConfirmDialog(null, pwd,"Contraseña:(Use Tab p/moverse o Mause)",JOptionPane.OK_CANCEL_OPTION);
        if(action < 0) {
            JOptionPane.showMessageDialog(null,"No se realiza Proceso, Gracias");
        } else {
            //comparo si la contraseña es apropiada
            if(variables_global.getPassword().equals(String.valueOf(pwd.getPassword()))) {//inicia trabajo para actualizar diferencias
                for(fi=0;fi<nobjetotabla;fi++)
                        {
                                try
                                    {
                                        cantidad = Float.valueOf(this.jtble_requiciciones.getValueAt(fi, 4).toString()).floatValue();
                                    }
                                catch (NumberFormatException nfe)
                                    {
                                        cantidad=0;
                                    }
                    // System.out.println("cachar error"+cadenafilas);
                            if (cantidad > 0)
                                    {
                                        cadenafilas+=""+this.jtble_requiciciones.getValueAt(fi, 4).toString()+":"+this.jtble_requiciciones.getValueAt(fi, 2).toString()+":"+this.jtble_requiciciones.getValueAt(fi, 2)+""+"\n";
                                    }
                        }//fin del for
                //System.out.println(s);
                //arreglo_articulos=cadenafilas.split(":");
                if(JOptionPane.showConfirmDialog(null, "Documento sera Guardado. Estan correcto sus Datos?")==0)
                    {
                       //this.quitardescripcion();
                        this.ponerpunto();
                        java.util.Vector arreglodearticulos=this.jtable_modelorequisicion.getDataVector();
                        String articulos_papostgresql=arreglodearticulos.toString();
                        articulos_papostgresql=articulos_papostgresql.replace('[','{');
                        articulos_papostgresql=articulos_papostgresql.replace(']','}');
                        articulos_papostgresql=articulos_papostgresql.replace("null",".");
                        String texto="select * from x1distribucion_almacen_traspa_requi("+variables_global.getId_empleado()+",'"+this.fechaamericana(this.jdc_fechadocto.getDate())+"','"+this.jtf_observaciones.getText().trim().toUpperCase()+"',"+variables_global.getalmacen()+",'"+articulos_papostgresql+"')";
                        System.out.println(texto);
                          rs=x.sieuno_executediversosv2(texto,variables_global.getconexiongral());
                            try {
                                while (rs.next())
                                        {
                                        controlfolio=rs.getInt(1);
                                        if (rs.getInt(1) > 0)
                                                {
                                                    while(jtable_modelorequisicion.getRowCount()>0)jtable_modelorequisicion.removeRow(0);
                                                    JOptionPane.showMessageDialog(null,"Requisicion Correcta, Gracias", "Sistema Integral(Requisicion Insumos) : Confirmacion",1);
                                                }
                                            else
                                                {
                                                    JOptionPane.showMessageDialog(null," Error Verifique sus Cantidades", "Sistema Integral(requisicion Insumos) : Error",1);
                                                }
                                        }
                                } catch(Exception e)
                                        {
                                            System.out.println(e.getMessage());
                                            JOptionPane.showMessageDialog(null," Recepcion Incorrecta ", "Sistema Integral(Requisicion Insumos) : Error",1);
                                        }
                 //this.btn_guardar.setVisible(false);
                }//fin del if qu confirmo guardar diferencia
            }
            else
                {
                    JOptionPane.showMessageDialog(null,"por Favor teclee su contraseña coreectamente, verifique mayusculas en teclado");
                }

        }
    }


  private void jtble_existenciaalmacenesMouseClicked(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
    }
      private void dioclick(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
         System.out.println("dio doble  click");

         int fila = jtb_articmasven.getSelectedRow();

          Object valor = jtb_articmasven.getValueAt(fila, 1);
          this.jep_imagen.setText("<img src=\"http://"+variables_global.getHostfotos()+"/"+variables_global.getcarpetaaplicacion()+"/fotos/"+jtb_articmasven.getValueAt(fila, 2).toString()+".JPG\" width=\"350\" height=\"220\" border=\"0\" alt=\"Foto Articulo\"></img>");
          this.jtf_idactual.setText(jtb_articmasven.getValueAt(fila, 1).toString());
          this.cargarexistencia(jtb_articmasven.getValueAt(fila, 2).toString());

        //setVisible(false);
    }

       private void dioclickalmacen(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
         System.out.println("dio doble  click");

         String arreglo_tiendas[]=null,idclisol="";
         arreglo_tiendas=this.jcbx_tiendas.getSelectedItem().toString().split(":");

         int filaalmacenes = jtble_existenciaalmacenes.getSelectedRow();
          String solicitocantidad="",caracteristicas=null;
          solicitocantidad=JOptionPane.showInputDialog("Cantidad a Solicitar:");
          caracteristicas=JOptionPane.showInputDialog("Caracteristicas u Observaciones:")+".";
          //arreglo_cantidad=solicitocantidad.toString().split("*");
          idclisol=this.find_idtiendac(jtble_existenciaalmacenes.getValueAt(filaalmacenes, 0).toString());
          if(Float.valueOf(solicitocantidad)>0)
            {
                        jtable_modelorequisicion.addRow(new Object[]{arreglo_tiendas[2],idclisol,jtble_existenciaalmacenes.getValueAt(filaalmacenes, 2).toString(),jtble_existenciaalmacenes.getValueAt(filaalmacenes, 3).toString(),solicitocantidad,caracteristicas});
            }


        

        //setVisible(false);
    }
private String fechaamericana(Date fe) {
       SimpleDateFormat formateadorestaeuropa = new SimpleDateFormat("yyyy-MM-dd");
       String cadenafecha="";
       cadenafecha= formateadorestaeuropa.format(fe);
       return cadenafecha;

    }
  
void LimpiarJTable()
    {
     //limpiar la tabla
        while(jtable_modelo.getRowCount()>0)jtable_modelo.removeRow(0);
    }
void LimpiarJTableexistencia()
    {
     //limpiar la tabla
        while(jtable_modeloexistencia.getRowCount()>0)jtable_modeloexistencia.removeRow(0);
    }
  private void verfotosestereporte()
    {
     this.cambiartamanofilas();
     int numerofilas=this.jtable_modelo.getRowCount();
             for(int i = 0 ;i < numerofilas; i++)
                {
                      jtable_modelo.setValueAt("<html><head></head><body><p style=\"margin-top: 0\"><img src=\"http://michelleptv.dyndns.org/distribucion/fotos/"+jtable_modelo.getValueAt(i, 4).toString()+".JPG\" width=\"90\" height=\"60\" border=\"0\" alt=\"Foto\"></img></p></body></html>", i,8);
                }

    }
private void cargarexistencia(String idpro)
    {
    Object valtie = null;
    this.LimpiarJTableexistencia();
    int numerotiendas=this.jtable_tiendas.getRowCount();
    String clave="",descripcion="",despartido[]=null;

               String texto="select * from x1sieuno_articulo_detalle(1,0,'','"+idpro+"') as (ida integer,min integer,max integer,exi double precision,idp integer,cod text,cndt integer,descor text,preve double precision,pre_re real,clavepro text)";
               try
                    {
                       rs2 = x.sieuno_executediversosv2(texto,variables_global.getconexiongral());
                       while (rs2.next())
                            {
                                  despartido=rs2.getString("descor").split(":");
                                jtable_modeloexistencia.addRow(new Object[]{despartido[0],despartido[2],rs2.getString ("clavepro"),despartido[1],rs2.getString ("min"),rs2.getString ("max"),rs2.getString("exi")});
                                clave=rs2.getString ("clavepro");
                                descripcion=despartido[1];
                            }
                    }
                catch(Exception e)
                {
                     System.out.println(e.getMessage());
                }
    
   
        jtable_modeloexistencia.addRow(new Object[]{"07","CREACIONES",clave,descripcion,"0","0","0"});
    }
 private String find_idtiendac(String titulo)  {

        String idcliente="",columtitulo="";
      for(int j = 0 ;j < this.jtable_tiendas.getRowCount() ; j++)
            {
                   columtitulo= jtable_tiendas.getValueAt(j, 1).toString();
                if(columtitulo.equals(titulo))
                    {
                            idcliente= jtable_tiendas.getValueAt(j, 3).toString();

                    }
            }
    //System.out.println("Esto encontro:"+columencontrado);
    return idcliente;
}

  private void quitarfotosestereporte()
    {
     int numerofilas=this.jtable_modelo.getRowCount();

             for(int i = 0 ;i < numerofilas; i++)
                {

                      jtable_modelo.setValueAt("", i,8);
                      jtb_articmasven.setRowHeight(i, 15);
                }
    }

  void cambiartamanofilas()
 {
     //limpiar la tabla


       int numerofilas=this.jtable_modelo.getRowCount();

             for(int i = 0 ;i < numerofilas; i++)
                {
                     jtb_articmasven.setRowHeight(i, 70);
                }
  }
private void ponerpunto()
    {
     int numerofilas=this.jtable_modelorequisicion.getRowCount();
        //this.cambiartamanofilas();
     String punto="";
             for(int i = 0 ;i < numerofilas; i++)
                {
                      punto=jtable_modelorequisicion.getValueAt(i, 5).toString().replace(",", "");
                      jtable_modelorequisicion.setValueAt(punto+".", i,5);
                      
                }
           //
    }


    private  void ayuda()
            {
                String punto1="1.- Este Reporte muestra Ventas Por Articulo en rango de Fechas determinado \n";
                String punto2="2.- Cada Boton tiene Una letra Resaltada el cual indica su metodo abreviado, uselo si desea mayor rapides ( ejemplo Alt+a obtendra ayuda automaticamente)\n";
                String punto3="3.- Algunos Reportes pueden tardar Unos minutos dependiento del rango de Fechas seleccionadas. \n ";
                String punto4="4.- Pase el Puntero del Mause sobre el Elemento este le mostrara una pequeña descripcion de lo qu hace. \n ";
                JOptionPane.showMessageDialog(null,""+punto1+punto2+punto3+punto4+"", "Sistema Integral(Reporte Articulos Mas Vendidos) : Ayuda",1);
            }
 private void crearcomentario()
          {
                 String retorno="";

        String comentario=JOptionPane.showInputDialog("Ingresa Tu Sugerencia o Comentario:");
        if (comentario.length()>0)
        {
            rs = x.sieuno_executediversosv2("select * from x1distribucion_bitacorainserta('"+comentario+"', 'Requision Traspaso');",variables_global.getconexiongral());
            try
            {

               while (rs.next())
                    {
                         retorno=rs.getString(1);
                   }
             }
            catch(Exception e)
            {
                System.out.println(e.getMessage());
            }
            if (retorno.equals("1"))
              {
                JOptionPane.showMessageDialog(null,"Gracias Tu comentario ha sido guardado", "Sistema Integral Comentarios",1);

              }

      }
    }

 private void contruir_reporte(Date fechai,Date fecha,int subfam,String idesq)
    {
        //fecha es la final del reporte
       
        String htmlabre="<html><BODY>",htmlcierra="</BODY></html>",colorabre="",colorcierra="";

        LimpiarJTable();//limpio si existen Registros
        DecimalFormat miformat = new DecimalFormat("###,###,###,###");
        int ii=0,idtienda=0,ndias=0,reg=0,noaten=0;
        //indicamos 7 columnas
        Object valtie = null;
        String serie1="",tienda="";

        SimpleDateFormat formato = new SimpleDateFormat("yyyy-MM-dd");

        String pFechai = formato.format(fechai);//fecha final de reporte
        String pFecha = formato.format(fecha);//fecha final de reporte

        float importe=0,totalpiezas=0,colexis=0,colmin=0,colmax=0;
        int rankin=0;
        //Voy por la venta del dia


        //serie1 = this.fechaeuropea(fechai)+" AL "+this.fechaeuropea(fecha);//fecha final de reporte

                String texto="select * from x1sieuno_articulo_masvendidosminmax('"+idesq+"',"+subfam+",'"+pFechai+"','"+pFecha+"',0)  as (id integer, can real,importe double precision,clavepro character varying(16),desclave character varying(80),itemclave character varying(80),nomfamclave character varying(30),nomtempo character varying(25),minimo integer,maximo integer,existencia double precision,precioventa double precision,precio_rebaja real);";
                 System.out.println(texto);
               try{
                 //rs = x.sieuno_ventas_cortedia(tienda,pFecha,i);
                 rs=x.sieuno_executediversosv2(texto,variables_global.getconexiongral());
                 while (rs.next())
                        {
                            rankin++;
                            totalpiezas+=rs.getFloat(2);
                            colexis=rs.getFloat("existencia");
                            colmin=rs.getFloat("minimo");
                            colmax=rs.getFloat("maximo");
                            colorabre="";
                            colorcierra="";
                            if (colexis<=0)
                                {
                                    colorabre="<b><font color=#CC0000>";
                                    colorcierra="<font></b>";
                                }
                            if ((colexis>0) && (colexis<=colmin))
                                {
                                    colorabre="<b><font color=\"YELLOW\">";
                                    colorcierra="<font></b>";
                                }
                            //importe+=rs.getFloat(3);
                            jtable_modelo.addRow(new Object[]{htmlabre+colorabre+rs.getString("nomfamclave")+colorcierra+htmlcierra,rs.getString("id"),rs.getString("clavepro"),htmlabre+colorabre+rs.getString("desclave")+colorcierra+htmlcierra,rs.getString("itemclave"),htmlabre+colorabre+miformat.format(rs.getFloat("can"))+colorcierra+htmlcierra,htmlabre+colorabre+rs.getString("minimo")+colorcierra+htmlcierra,htmlabre+colorabre+rs.getString("maximo")+colorcierra+htmlcierra,htmlabre+colorabre+rs.getString("existencia")+colorcierra+htmlcierra,""});
                        }
                    }
                     catch(Exception e)
                     {
                             System.out.println(e.getMessage());
                     }

            jtable_modelo.addRow(new Object[]{"<html><h3><b>Totales: "+"</b></h3></html>","","<html><h3><b>"+miformat.format(totalpiezas)+"</b></h3></html>","","","<html><h3><b>"+miformat.format(importe)+"</b></h3></html>","","",""});
/*
            titulografico="Grafica Ventas X Proveedor : "+this.fechaeuropea(fechai)+" A " + this.fechaeuropea(fecha)+" Total="+miformat.format(importe)+"";

            variables_global.settitulografica_artmasvxp(titulografico);
*/
/*
            int numerofilas=this.jtable_modelo.getRowCount();
             rankin=0;

             for(int i = 0 ;i < numerofilas; i++)
                {
                     jtb_articmasven.setRowHeight(i, 70);
                }


             for(int i = 0 ;i < numerofilas; i++)
                {
                 valtie=this.jtable_modelo.getValueAt(i,2);
                 serie1=this.jtable_modelo.getValueAt(i,8).toString();

                 importe2=Float.valueOf(valtie.toString().replace(",","").replace(".",""));
                 totporcen=(Float.valueOf(valtie.toString().replace(",","").replace(".",""))/importe)*100;
                 totporcenacum+=totporcen;
                 jtable_modelo.setValueAt(miformat.format(totporcen)+"%",i,6);
                 jtable_modelo.setValueAt(miformat.format(totporcenacum)+"%",i,7);
                 if (serie1.length()>12)
                        {
                            serie1=serie1.substring(0, 12);
                        }

                 if(totporcenacum < 91)
                        {
                            dataset.addValue(importe2,this.jtable_modelo.getValueAt(i,0).toString()+"="+serie1,"Sub Familias");
                             rankin++;
                        }
                 else
                        {
                            importe3+=importe2;
                        }
                 }
                 dataset.addValue(importe3, rankin+" sub Familias 10% Restantes","Sub Familias");

                 variables_global.setdatasetarmasvp(dataset);
 */
 }
    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new articulos_sie_traspaso_requisicion().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JButton jbtn_generareporte;
    private javax.swing.JButton jbtn_guardar;
    private javax.swing.JComboBox jcbx_tiendas;
    private com.toedter.calendar.JDateChooser jdc_fechadocto;
    private com.toedter.calendar.JDateChooser jdc_fechafinal;
    private com.toedter.calendar.JDateChooser jdc_fechainicial;
    private javax.swing.JEditorPane jep_imagen;
    private javax.swing.JMenuItem jmni_escape;
    private javax.swing.JMenuItem jmni_guardar;
    private javax.swing.JMenuItem jmni_salir;
    private javax.swing.JRadioButton jrbtn_estemes;
    private javax.swing.JRadioButton jrbtn_mesactuaante;
    private javax.swing.JRadioButton jrbtn_mespasada;
    private javax.swing.JTable jtb_articmasven;
    private javax.swing.JTable jtble_existenciaalmacenes;
    private javax.swing.JTable jtble_requiciciones;
    private javax.swing.JTextField jtf_idactual;
    private javax.swing.JTextField jtf_observaciones;
    // End of variables declaration//GEN-END:variables

}
